'use strict';

exports.__esModule = true;

var _redux = require('redux');

var _reactRouterRedux = require('react-router-redux');

var _reduxThunk = require('redux-thunk');

var _reduxThunk2 = _interopRequireDefault(_reduxThunk);

var _loadingMiddleware = require('./middlewares/loadingMiddleware');

var _loadingMiddleware2 = _interopRequireDefault(_loadingMiddleware);

var _promiseMiddleware = require('./middlewares/promiseMiddleware');

var _promiseMiddleware2 = _interopRequireDefault(_promiseMiddleware);

var _errorMiddleware = require('./middlewares/errorMiddleware');

var _errorMiddleware2 = _interopRequireDefault(_errorMiddleware);

var _api = require('./libs/api');

var _api2 = _interopRequireDefault(_api);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || _redux.compose;

exports.default = function (reducer, history) {
  var middlewares = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];

  var store = (0, _redux.createStore)(reducer, composeEnhancers(_redux.applyMiddleware.apply(undefined, [_reduxThunk2.default.withExtraArgument(_api2.default), _loadingMiddleware2.default, _promiseMiddleware2.default, _errorMiddleware2.default, (0, _reactRouterRedux.routerMiddleware)(history)].concat(middlewares))));

  return store;
};